<?php
	ini_set('date.timezone','Asia/Shanghai');
	header("content-type:text/html;charset=utf-8");
	header("Access-Control-Allow-Origin: *");
   	$mysql_conf = array(
        'host'    => '127.0.0.1', 
        'db'      => 'fang', 
        'db_user' => 'root', 
        'db_pwd'  => 'root', 
    );

$nickname = $_GET["nickname"];
$avatarUrl = $_GET["avatarUrl"];
$openid = $_GET["openid"];
// $nickname = '黄先生';
// $avatarUrl = 'dajksdhgakjchbzkhwks';
// $openid = 'alskhc8ashdlkja89hkj';

 $mysqli = @new mysqli($mysql_conf['host'],$mysql_conf['db_user'],$mysql_conf['db_pwd']);

	    if ($mysqli->connect_errno) {
	        die("could not connect to the database:\n" . $mysqli->connect_error);//诊断连接错误
	    }
	    $mysqli->query("set names 'utf8';");//编码转化
	    $select_db = $mysqli->select_db($mysql_conf['db']);
	    if (!$select_db) {
	        die("could not connect to the db:\n" .  $mysqli->error);
	    }
$sql = "INSERT INTO user (nickname, avatarurl, openid) VALUES ('$nickname', '$avatarUrl', '$openid')";
if ($mysqli->query($sql) === TRUE) {
	    echo "注册成功！";
	} else {
	    echo "Error: " . $sql . "<br/>" . $mysqli->error;
	}

$mysqli->close();


?>
